package com.kly.cashmall.module.home.home_tab.tab_view;


import androidx.annotation.DrawableRes;


import com.kly.cashmall.module.home.home_tab.Route;
import com.kly.cashmall.module.home.home_tab.tab_container.TabController;

import java.io.Serializable;

/**
 * @author
 * @date 2018/1/26
 */
public class MenuTabInfo implements Serializable {

  public static final String TAG_INFO = "MenuTabInfo";

  public static final String TAG_HOME = Route.APP_ACTION_SCHEME +Route.MODULE_ACTION_HOME;
  public static final String
          TAG_LOAN_PRODUCTS =  Route.APP_ACTION_SCHEME + Route.MODULE_ACTION_PRODUCT;
  public static final String
          TAG_LOAN_ORDERS =  Route.APP_ACTION_SCHEME  + Route.MODULE_ACTION_ORDER;
  public static final String
          TAG_MINE_CENTER = Route.APP_ACTION_SCHEME + Route.MODULE_ACTION_ACCOUNT;

  public String title;
  public String imgUrl;
  public String imgCheckedUrl;
  public String jumpValue;
  public int needLogin = 0;

  public @DrawableRes
  int iconResource;

  public MenuTabInfo() {

  }
  public MenuTabInfo(String name, String action,int needLogin) {
    this.title = name;
    this.jumpValue = action;
    this.needLogin = needLogin;
  }

  public boolean isMatch(String regex) {
    return TabController.tagMatchRule(regex, jumpValue);
  }

  public static MenuTabInfo buildHomeMainMenuAction(HomeMainMenuAction responseBean){
    MenuTabInfo tabInfo = new MenuTabInfo(responseBean.getTitle(), responseBean.getJumpUrl(),responseBean.isNeedLogin() ? 1 : 0);
    tabInfo.imgUrl = responseBean.getImgUrl();
    tabInfo.imgCheckedUrl = responseBean.getImgCheckedUrl();
    tabInfo.needLogin = responseBean.isNeedLogin() ? 1 : 0;
    return tabInfo;
  }

  public int needLogin() {
    return needLogin;
  }
}
